<?php
require_once('vobject/ImageVO.php');
require_once('connexion/Mysql.php');
require_once('connexion/SQLRequest.php');
/**
 * Class FlashGallery
 */
class FlashGallery
{
	
	var $db;
	
    function FlashGallery()
 		{
 				$this->methodTable["getAllImages"]['access'] = 'remote';
       			$this->methodTable["getAllImages"]['description'] = 'Return the images list :)';
				
				$this->db = Mysql::getInstance( '127.0.0.1', 'flash_gallery', 'root', '' );	
 		}
	/**
	  * getAllImages
	  * @returns all images from the database
	  */
	 public function getAllImages() 
	 {
       	$rest = array();
		
		$this->db->Open();
		
		$request = SQLRequest::getRequest( "image" );
		$result = $this->db->Query( $request );
		
		while( $data = mysql_fetch_assoc( $result ) )
        {
            $id 			= $data['image_id'];
            $name 			= $data['image_name'];
            $description	= $data['image_description'];
			$width 			= $data['image_width'];
			$height 		= $data['image_height'];
	    	
			$values = array(
							"id"=>$id,
							"name"=>$name,
							"description"=>$description,
							"width"=>$width,
							"height"=>$height
							);
			
	    	$image = new ImageVO( $values );
            array_push($rest, $image);
        }
        
		$this->db->Close();

        // on retourne le tableau
        return $rest;
	 }
}
?>